<template>
  			<el-form ref="form" :model="form" label-width="80px" label-position='top'>
				<div style="height:80px;border: 1px solid #DCDFE6;border-radius: 5px;margin-bottom:15px;display: flex;align-items: center;justify-content: space-between;">
					<div style="flex: 1;">
						<el-form-item style="margin-bottom:0;border-bottom: 1px solid #DCDFE6;">
							<span style="display: inline-block;padding:0 15px;color: #ccc;">从</span>
							<span>{{form.transferType==1?'商家账户':'个人账户'}}</span>
						</el-form-item>
						<el-form-item style="margin-bottom:0;">
							<span style="display: inline-block;padding:0 15px;color: #ccc;">到</span>
							<span>{{form.transferType==2?'商家账户':'个人账户'}}</span>
						</el-form-item>
					</div>
					<div @click="zhuanhuan" style="background-color: #F5F7FA;width: 100px;height: 100%;border-left: 1px solid #DCDFE6;display: flex;align-items: center;justify-content: center;">
						<i class="el-icon-sort" style="font-size: 24px;color: #03a9f4;font-weight: bold;"></i>
					</div>
				</div>
				
				<el-form-item label="划转数量">
					<el-input-number v-model="form.sweet" :min="0"></el-input-number>
				</el-form-item>
				<el-form-item label="交易密码">
					<el-input v-model="form.password" type="password" clearable></el-input>
				</el-form-item>

				<el-form-item>
					<el-button type="primary" @click="onSubmit">确认</el-button>
				</el-form-item>
			</el-form>
</template>
<script>
export default {
  data () {
    return {
      form: {
					mid: localStorage.getItem('merchantId'),
					password: "",
					sweet: 0,
					transferType: 1,//1 商户划转到个人 2个人划转到商户
				}
    }
  },
  methods: {
    zhuanhuan(){
      this.form.transferType == 1?this.form.transferType = 2:this.form.transferType = 1;
    },
    onSubmit() {
				this.$http.post(this.$api.sweetTransfer, this.form).then(res => {
					if (res.code == 0) {
						this.$message({
							type: 'success',
							message: '糖果划转成功！'
						})
             this.$emit('success')
						
					} else {
            this.$emit('error')
						this.$message.error('糖果划转失败！' + res.msg)
					}
				})
			},
  }
}
</script>